<template>
  <div>
    <span class="el-menu__title" style="text-align: center;font-size: medium;color: #0682C5">请假</span>
    <div style="margin-top: 10px">
      <el-form ref="salary" label-width="80px"
               label-position="right" style="margin-top: 15px">
        <el-form-item label="用户名">
          <el-col :span="4">
            <el-input v-model="login.username"  readonly maxlength="15"
                      placeholder="请输入密码"></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="开始时间">
          <el-col :span="4">
            <el-input v-model="begTime" clearable maxlength="15"
                      placeholder="请输入开始时间"></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="结束时间">
          <el-col :span="4">
            <el-input v-model="endTime" clearable maxlength="15"
                      placeholder="请输入结束时间"></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="请假事由">
          <el-col :span="4">
            <el-input v-model="note" clearable type="textarea"
                      placeholder="请输入请假事由"></el-input>
          </el-col>
        </el-form-item>
        <el-button type="primary" @click="registerUsers()">请假</el-button>
      </el-form>

      <el-row v-show="sa">
        <span style="color: #0682C5">实发： </span>
        <span style="color: black"> {{$store.getters.getLoginParam.salary}}</span>
      </el-row>
      <el-row></el-row>
      <el-row></el-row>
    </div>
  </div>
</template>

<script>
    import {postRequest} from "../../utils/api";

    export default {
        name: "Sunday",
        data() {
            return {
                begTime: '',
                endTime: '',
                note: '',
                login: {},

            }

        },
        methods: {
            registerUsers() {
                postRequest(
                    '/sunday/register',
                    {
                        'username': this.login.username,
                        'begTime': this.begTime,
                        'endTime': this.endTime,
                        'note': this.note,
                    }
                ).then(res => {
                    // 密码修改校验成功
                    if (res && res.flag === '1') {
                        // 保存登录信息
                        this.$message.success(' 请假录入成功');
                        // replace 不可回退  铺设可以
                        //this.$router.push('/Login')
                    } else {
                        this.loading = false
                        // 修改失败
                        this.$message.error(res.msg + '!');
                    }
                })

            },
            getLoginInfo() {
                this.login = JSON.parse(this.$store.state.loginParam)
            }

        },
        mounted() {
            this.getLoginInfo()
        }

    }
</script>

<style scoped>

</style>
